import { createApp } from "vue";
import App from "./App.vue";

import jmash, {
  store,
  routerRef,
  directive,
  useUserStore,
  getQueryParams,
  i18n,
  updateViteMetaEnv,
  axiosConfig,
} from "jmash-core";



// 环境变量
const viteMetaEnv: ImportMetaEnv = import.meta.env;
const metaEnv = updateViteMetaEnv(viteMetaEnv);
axiosConfig(metaEnv);

import "@/permission";

import "element-plus/dist/index.css"
import "element-plus/theme-chalk/index.css";
import "jmash-core/dist/style.css";
import "jmash-dict/dist/style.css";

const app = createApp(App);
// Query参数
const queryParams = getQueryParams();
if (queryParams.tenant) {
  useUserStore().user.tenant = queryParams.tenant;
} else {
  useUserStore().user.tenant = "rbac";
}

import rbac from "./index";
import dict from "jmash-dict";

app
  .use(jmash)
  .use(dict)
  .use(rbac)
  .use(directive)
  .use(store)
  .use(routerRef.value)
  .use(i18n)
  .mount("#app");
